dojo.declare("DVendorProductCatalogsPg", wm.Page, {
	start: function() {
		
	}, 
	"preferredDevice": "desktop",

	itemsDojoGridImageUrlFormat: function( inValue, rowId, cellId, cellField, cellObj, rowObj) {
		 try {
            var file = "services/FileUploadDownload.download?method=downloadFile&fileName=" + inValue;
            return '<img  style="height: 50px;" src="' + inValue + '" />';
        } catch (e) {
            console.error('ERROR IN dojoGrid2PicurlFormat: ' + e);
        }
	},
	itemsNewButtonClick1: function(inSender) {
		this.dfImageUpload.resetData();
        
	},
    
    calculateFinalprice: function() {
    
        var vatPercent = this.txtVAT.getDataValue();
        var eduCess = this.txtEduCess.getDataValue();
        var serviceTax = this.txtServiceTax.getDataValue();
        var serviceCharge = this.txtServiceCharge.getDataValue();
        var tpsPercInc = this.txtTpsShareIncPer.getDataValue();
        var tpsPerExcl = this.txtTpsShareExclPer.getDataValue();
        var tpsShareInc = this.txtTpsShareIncl.getDataValue();
        var tpsShareExcl = this.txtTpsShareExcl.getDataValue();
        var basePrice = this.txtBasePrice.getDataValue();
        var finalPrice = 0;
    
        if (vatPercent !== 0) {
            finalPrice = finalPrice + ((vatPercent / 100) * basePrice);
            if (eduCess !== 0) {
                var eduCessPercent = vatPercent * (eduCess/100);
                finalPrice = finalPrice + (eduCessPercent / 100) * basePrice;
            }
    
    
        }
        if (serviceTax !== 0) {
            finalPrice = finalPrice + (serviceTax / 100) * basePrice;
        }
        if (serviceCharge !== 0) {
            finalPrice = finalPrice + (serviceCharge / 100) * basePrice;
        }
        //if (tpsPercInc != 0) {
        //finalPrice  = finalPrice + (tpsPercInc / 100) * basePrice;
        //}
        //else
        if (tpsPerExcl !== 0) {
    
            finalPrice = finalPrice + (tpsPerExcl / 100) * basePrice;
        }
        // else if (tpsShareInc != 0) {
        ///  finalPrice  = finalPrice + 
        //}
        else if (tpsShareExcl !== 0) {
            tpsShareExcl = tpsShareExcl / 1;
            finalPrice = finalPrice + tpsShareExcl;
        }
    
        basePrice = basePrice / 1;
        finalPrice = finalPrice + basePrice; /* */
        this.priceEditor1.setDataValue(finalPrice);
    
    },
	itemsSaveButtonClick: function(inSender) {
		this.calculateFinalprice();
        
        this.itemsLiveForm1.saveDataIfValid();
	},
	txtBasePriceChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		    this.calculateFinalprice();
	},
	txtVATChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtEduCessChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtServiceTaxChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtServiceChargeChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtTpsShareIncPerChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtTpsShareExclPerChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtTpsShareInclChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	txtTpsShareExclChange: function(inSender, inDisplayValue, inDataValue, inSetByCode) {
		this.calculateFinalprice();
	},
	_end: 0
});